#ifndef __UI_CONTRACT_TRADE_H__
#define __UI_CONTRACT_TRADE_H__

#include <afxwin.h>
#include "IOptionUi.h"
#include "IOptionsControl.h"



class CUiContractTrade : public virtual IUiContractTrade
{
INIT_CLASS_SINGLETON(CUiContractTrade)
public:
	const bool Init(const void * pvdPara, char * pszMsgTxt, int iMsgTxtSize);
	const void SetGridInfoId(int iId);
	const void SetBidButtonId(int iId);
	const void SetAskButtonId(int iId);
	const void SetBilateralQuotationsButtonId(int iId);
	const void SetQuotationImgId(int iId);
	const void SetCoveredChkBox(int iId);
	const void SetBidPriEditId(int iId);
	::HWND GetBidPriEditHwnd(void * ptrContract);
	const void SetAskPriEditId(int iId);
	::HWND GetAskPriEditHwnd(void * ptrContract);
	const void SetBidVolEditId(int iId);
	::HWND GetBidVolEditHwnd(void * ptrContract);
	const void SetAskVolEditId(int iId);
	::HWND GetAskVolEditHwnd(void * ptrContract);
	::HWND GetQuotationImgHwnd(void * ptrContract);
	const bool UpdGridVal(void * ptrContract, const char * pszName);
	const bool SetBidAskButton(void * ptrContract, const char * pszName);
	const bool UpdTime(void * ptrContract);
	const bool UpdQuot(void * ptrContract);
	const void ChangeSkin(void * ptrContract, bool bColorFlg = false);
	::BOOL OnMouseWheel(void * ptrContract, UINT nFlags, short zDelta);
	void OnButtonUp(void * ptrContract, int iAtX, int iAtY);
	void OnMouseMove(void * ptrContract, int iAtX, int iAtY);
	void OnPaint(void * ptrContract);
	bool InitContractTradeForm(void * ptrContract, PNewContractTradeForm ptrNewFormFun, string & strInitInfo, string & strMsg);
	const int MaxBidVol(void * ptrContract);
	const int MaxAskVol(void * ptrContract);
	const int MaxRate(void * ptrContract);
	const void BidPriToAskPri(void * ptrContract, int iRate);
	const void AskPriToBidPri(void * ptrContract, int iRate);
	const bool BidQuotation(void * ptrContract, PRiskMsg ptrRiskMsg, void * ptrForm);
	const bool AskQuotation(void * ptrContract, PRiskMsg ptrRiskMsg, void * ptrForm, bool bCovered);
	const bool BilateralQuotation(void * ptrContract, PRiskMsg ptrRiskMsg, void * ptrForm, bool bCovered);
    const void DestructForm(void * ptrContract);
	
private:
    ::HWND GetGridInfoHwnd(IContract * ptrContract);
	CWnd * GetBidButtonWnd(IContract * ptrContract);	
	CWnd * GetAskButtonWnd(IContract * ptrContract);
	::HWND GetBilateralQuotationsButtonHwnd(IContract * ptrContract);
	CButton * GetCoveredChkBox(IContract * ptrContract);
	CWnd * GetWnd(IContract * ptrContract, const char * pszName);
	::HWND GetHwnd(IContract * ptrContract, const char * pszName);
	void InitInputCtrl(::HWND hCtrl, const char * pszTxt, int iIdx);
	bool CheckRisk(IContract * ptrContract, PRiskMsg ptrRiskMsg, void * ptrForm);
	const bool Quotation(IContract * ptrContract, PRiskMsg ptrRiskMsg, void * ptrForm, int iDir, ::HWND hBidPriHwnd, ::HWND hBidVolHwnd, ::HWND hAskPriHwnd, ::HWND hAskVolHwnd);
	const bool ChkInputData(IContract * ptrContract, PRiskMsg ptrRiskMsg, void * ptrForm, int iDir); 
	const bool ChkPri(IContract * ptrContract, int iDir, string & strMsg);
	const bool ChkVol(IContract * ptrContract, int iDir, string & strMsg);
	const bool ChkClosePri(IContract * ptrContract, int iDir, string & strMsg);
	const bool ChkLastPri(IContract * ptrContract, int iDir, string & strMsg);
};


#endif//__UI_CONTRACT_TRADE_H__